{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [],
   "source": [
    "from math import exp\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "%matplotlib inline\n",
    "\n",
    "# 导入鸢尾花数据集\n",
    "from sklearn.datasets import load_iris\n",
    "# 将数据集切分为训练数据集和测试数据集\n",
    "from sklearn.model_selection import train_test_split"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [],
   "source": [
    "# data\n",
    "def create_data():\n",
    "    iris = load_iris()\n",
    "    # 将鸢尾花数据集转换成DataFrrame数据结构\n",
    "    df = pd.DataFrame(iris.data, columns=iris.feature_names)\n",
    "    # 预测目标值为：[0,1,2]\n",
    "    df['label'] = iris.target\n",
    "    df.columns = ['sepal length', 'sepal width', 'petal length', 'petal width', 'label']\n",
    "    # 取出花萼长度，花萼宽度，以及样本标签，三列数据\n",
    "    data = np.array(df.iloc[:100, [0,1,-1]])\n",
    "    # print(data)\n",
    "    return data[:,:2], data[:,-1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [],
   "source": [
    "X, y = create_data()\n",
    "# 切分了数据集，0.7的训练数据，0.3的测试数据\n",
    "X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [],
   "source": [
    "class LogisticReressionClassifier:\n",
    "    def __init__(self, max_iter=200, learning_rate=0.01):\n",
    "        # 默认迭代次数为200次\n",
    "        # 步长为0.01\n",
    "        self.max_iter = max_iter\n",
    "        self.learning_rate = learning_rate\n",
    "\n",
    "    # 压缩函数的定义\n",
    "    def sigmoid(self, x):\n",
    "        return 1 / (1 + exp(-x))\n",
    "\n",
    "    def data_matrix(self, X):\n",
    "        data_mat = []\n",
    "        for d in X:\n",
    "            # *d是元组tuple的unpack操作\n",
    "            data_mat.append([1.0, *d])\n",
    "        return data_mat\n",
    "\n",
    "    def fit(self, X, y):\n",
    "        # label = np.mat(y)\n",
    "        data_mat = self.data_matrix(X)  # m*n\n",
    "        # 初始化系数为0\n",
    "        # 递归下降时，未知数为w，b\n",
    "        # b = w_0 * x_0, 其中：x_0 = 1, w_0 = b\n",
    "        self.weights = np.zeros((len(data_mat[0]), 1), dtype=np.float32)\n",
    "\n",
    "        for iter_ in range(self.max_iter):\n",
    "            for i in range(len(X)):\n",
    "                result = self.sigmoid(np.dot(data_mat[i], self.weights))\n",
    "                error = y[i] - result\n",
    "                self.weights += self.learning_rate * error * np.transpose(\n",
    "                    [data_mat[i]])\n",
    "        print('LogisticRegression Model(learning_rate={},max_iter={})'.format(\n",
    "            self.learning_rate, self.max_iter))\n",
    "\n",
    "    # def f(self, x):\n",
    "    #     return -(self.weights[0] + self.weights[1] * x) / self.weights[2]\n",
    "\n",
    "    def score(self, X_test, y_test):\n",
    "        right = 0\n",
    "        X_test = self.data_matrix(X_test)\n",
    "        for x, y in zip(X_test, y_test):\n",
    "            result = np.dot(x, self.weights)\n",
    "            if (result > 0 and y == 1) or (result < 0 and y == 0):\n",
    "                right += 1\n",
    "        return right / len(X_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "LogisticRegression Model(learning_rate=0.01,max_iter=200)\n"
     ]
    }
   ],
   "source": [
    "lr_clf = LogisticReressionClassifier()\n",
    "lr_clf.fit(X_train, y_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1.0"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "lr_clf.score(X_test, y_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.legend.Legend at 0x129f8c350>"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD4CAYAAAD8Zh1EAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nO3deXxU5dn/8c9liCzKIpsCAQJEcUEEQRRRNmtRpGhdEKu2uOGCXbS11T597CNPn9+j9afW/tiK+4paq4jWpa0kiAhoEAUFrQlrArKEHZKQ5fr9MRMIY0hOkjNz7jlzvV8vX2TOHM7c94xenpzzve4RVcUYY0zyOyLoARhjjPGHFXRjjAkJK+jGGBMSVtCNMSYkrKAbY0xINAnqhdu3b6+ZmZlBvbwxxiSlJUuWbFXVDjU957mgi0gakAsUquqYmOcmAA8ChdFNU1T18dqOl5mZSW5urteXN8YYA4jI2sM9V58z9J8DK4FWh3n+ZVW9vT4DM8YY4x9P19BFJAO4CKj1rNsYY0xwvN4U/RPwa6Cyln0uE5FlIvKqiHStaQcRmSgiuSKSu2XLlvqO1RhjTC3qvOQiImOAzaq6RESGH2a3N4FZqloqIjcDzwAjY3dS1ZnATICBAwfamgPGmECUlZVRUFBASUlJ0EM5rGbNmpGRkUF6errnv+PlGvoQYKyIjAaaAa1E5HlVvaZqB1Utqrb/48AfPY/AGGMSrKCggJYtW5KZmYmIBD2c71BVioqKKCgooEePHp7/Xp2XXFT1HlXNUNVMYDwwt3oxBxCRTtUejiVy89QYY5xUUlJCu3btnCzmACJCu3bt6v0bRINz6CIyGchV1TnAz0RkLFAObAMmNPS4xhiTCK4W8yoNGV+9Crqq5gA50Z/vrbb9HuCeer+6MSE1e2khD773NRt2FNO5TXPuGtWbS/p3CXpYJuSs9d8Yn81eWsg9ry2ncEcxChTuKOae15Yze2lhnX/XpI53332X3r17k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EFXRjjAmJ/w9fQoHSLXXcWwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "x_ponits = np.arange(4, 8)\n",
    "y_ = -(lr_clf.weights[1]*x_ponits + lr_clf.weights[0])/lr_clf.weights[2]\n",
    "plt.plot(x_ponits, y_)\n",
    "\n",
    "#lr_clf.show_graph()\n",
    "plt.scatter(X[:50,0],X[:50,1], label='0')\n",
    "plt.scatter(X[50:,0],X[50:,1], label='1')\n",
    "plt.legend()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
